package com.lagou.edu.service;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Mail 服务模块的 Feign 远程调用接口声明
 */
@Primary
@FeignClient(
        value = "lagou-service-email",
        fallback = MailServiceFeign.MailServiceFallbackImpl.class
)
public interface MailServiceFeign {
    /**
     * 发送验证码到邮箱，true成功，false失败
     * @param email
     * @return true/false
     */
    @RequestMapping("/api/email/{email}/{code}")
    public String sendMail(@PathVariable("email")String email, @PathVariable("code")String code);

    @Component
    class MailServiceFallbackImpl implements MailServiceFeign {
        @Override
        public String sendMail(String email, String code) {
            return "false";
        }
    }
}
